package com.ruoyi.control.service.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; //添加
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.control.mapper.MainventilatorOneMapper;
import com.ruoyi.control.domain.MainventilatorOne;
import com.ruoyi.control.service.IMainventilatorOneService;

/**
 * 主通风机1号风机Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-08
 */
@Service
public class MainventilatorOneServiceImpl extends ServiceImpl<MainventilatorOneMapper, MainventilatorOne> implements IMainventilatorOneService //修改
{
    @Autowired
    private MainventilatorOneMapper mainventilatorOneMapper;

    /**
     * 查询主通风机1号风机
     * 
     * @param address 主通风机1号风机主键
     * @return 主通风机1号风机
     */
    @Override
    public MainventilatorOne selectMainventilatorOneByAddress(String address)
    {
        return mainventilatorOneMapper.selectMainventilatorOneByAddress(address);
    }

    /**
     * 查询主通风机1号风机列表
     * 
     * @param mainventilatorOne 主通风机1号风机
     * @return 主通风机1号风机
     */
    @Override
    public List<MainventilatorOne> selectMainventilatorOneList(MainventilatorOne mainventilatorOne)
    {
        return mainventilatorOneMapper.selectMainventilatorOneList(mainventilatorOne);
    }

    /**
     * 新增主通风机1号风机
     * 
     * @param mainventilatorOne 主通风机1号风机
     * @return 结果
     */
    @Override
    public int insertMainventilatorOne(MainventilatorOne mainventilatorOne)
    {
        return mainventilatorOneMapper.insertMainventilatorOne(mainventilatorOne);
    }

    /**
     * 修改主通风机1号风机
     * 
     * @param mainventilatorOne 主通风机1号风机
     * @return 结果
     */
    @Override
    public int updateMainventilatorOne(MainventilatorOne mainventilatorOne)
    {
        mainventilatorOne.setUpdateTime(DateUtils.getNowDate());
        return mainventilatorOneMapper.updateMainventilatorOne(mainventilatorOne);
    }

    /**
     * 批量删除主通风机1号风机
     * 
     * @param addresss 需要删除的主通风机1号风机主键
     * @return 结果
     */
    @Override
    public int deleteMainventilatorOneByAddresss(String[] addresss)
    {
        return mainventilatorOneMapper.deleteMainventilatorOneByAddresss(addresss);
    }

    /**
     * 删除主通风机1号风机信息
     * 
     * @param address 主通风机1号风机主键
     * @return 结果
     */
    @Override
    public int deleteMainventilatorOneByAddress(String address)
    {
        return mainventilatorOneMapper.deleteMainventilatorOneByAddress(address);
    }

    @Override
    public List<MainventilatorOne> getList() {
        List<MainventilatorOne> mainventilatorOneList = new ArrayList<>();
        List<String> mainventilatorOne = Arrays.asList("zs_fengji1_bpq_Ia","zs_fengji1_bpq_Ib","zs_fengji1_bpq_Ic","zs_fengji1_bpq_pinlv_out", "zs_fengji1_bpq_Uab","zs_fengji1_bpq_Ubc","zs_fengji1_bpq_Uca","zs_fengji1_temp_1_A","zs_fengji1_temp_1_B",
                "zs_fengji1_temp_1_Back", "zs_fengji1_temp_1_C","zs_fengji1_temp_1_Front","zs_fengji1_temp_2_A","zs_fengji1_temp_2_B","zs_fengji1_temp_2_Back", "zs_fengji1_temp_2_C","zs_fengji1_temp_2_Front", "zs_fengji1_zd_x","zs_fengji1_zd_y","zs_fengji1_fuya",

                "zs_fengji2_bpq_Ia","zs_fengji2_bpq_Ib","zs_fengji2_bpq_Ic", "zs_fengji2_bpq_pinlv_out","zs_fengji2_bpq_Uab", "zs_fengji2_bpq_Ubc","zs_fengji2_bpq_Uca","zs_fengji2_temp_1_A","zs_fengji2_temp_1_B", "zs_fengji2_temp_1_Back","zs_fengji2_temp_1_C",
                "zs_fengji2_temp_1_Front","zs_fengji2_temp_2_A","zs_fengji2_temp_2_B", "zs_fengji2_temp_2_Back","zs_fengji2_temp_2_C","zs_fengji2_temp_2_Front","zs_fengji2_zd_x","zs_fengji2_zd_y","zs_fengji2_fuya",

                "zs_fengji1_fengliang","zs_fengji1_fengsu","zs_fengji1_huanwen");
        for (String s : mainventilatorOne) {
            MainventilatorOne mainventilatorOne1 = mainventilatorOneMapper.selectMainventilatorOneByName(s);
            if (mainventilatorOne1 != null && mainventilatorOne1.getValue() != null){
                Double dValue = Double.valueOf(mainventilatorOne1.getValue());
                mainventilatorOne1.setValue(String.format("%.2f",dValue));
            }
            mainventilatorOneList.add(mainventilatorOne1);
        }
        return mainventilatorOneList;
    }

    @Override
    public List<MainventilatorOne> getDF() {
        List<MainventilatorOne> mainventilatorOneList = new ArrayList<>();
        List<String> strings = Arrays.asList("zs_fengji1_diefa_kdw", "zs_fengji1_diefa_gdw","zs_fengji2_diefa_kdw","zs_fengji2_diefa_gdw");
        for (String string : strings) {
            MainventilatorOne mainventilatorOne1 = mainventilatorOneMapper.selectMainventilatorOneByName(string);
            mainventilatorOneList.add(mainventilatorOne1);
        }
        return mainventilatorOneList;
    }

    @Override
    public List<MainventilatorOne> getDyDpTfValueList() {
        return mainventilatorOneMapper.getDyDpTfValueList();
    }
}
